package com.shamar.blog.enums;

/**
 * 使用枚举表述常量数据字典
 */
public enum BlogUserStateEnum {

	NORMAL(1, "正常"), BANNED(0, "封禁"),NULL_USER_INFO(-1,"传入了空的信息"),NO_USER('2',"没有这个用户或密码错误");

	private int state;

	private String stateInfo;

	private BlogUserStateEnum(int state, String stateInfo) {
		this.state = state;
		this.stateInfo = stateInfo;
	}

	public int getState() {
		return state;
	}

	public String getStateInfo() {
		return stateInfo;
	}

	/**
	 * 依据传入的state返回相应的enum值
	 * @param index
	 * @return
	 */
	public static BlogUserStateEnum stateOf(int index) {
		for (BlogUserStateEnum state : values()) {
			if (state.getState() == index) {
				return state;
			}
		}
		return null;
	}

}